Skip to content

Add Two Gateway Controllers to Postgres Test Suite to always test based on eventing#1885

Merged
renuka-fernando merged 3 commits into
wso2:mainfrom
VirajSalaka:it-two-controller
Jun 11, 2026
Merged

Add Two Gateway Controllers to Postgres Test Suite to always test based on eventing#1885
renuka-fernando merged 3 commits into
wso2:mainfrom
VirajSalaka:it-two-controller

Conversation

@VirajSalaka

Copy link
Copy Markdown
Contributor

Purpose

Explain why this feature or fix is required. Describe the underlying problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc.

Goals

Describe what solutions this feature or fix introduces to address the problems outlined above.

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI. Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary

This PR adds a two-controller Postgres test topology to the gateway integration test suite to enable testing based on eventing. The changes establish a runtime-facing controller replica alongside the primary gateway controller within the Postgres-backed test environment.

Key Changes

Test Infrastructure Updates:

  • Modified the PostgreSQL gateway integration test workflow to enable the two-controller setup via IT_GATEWAY_CONTROLLER_RUNTIME=true environment variable
  • Updated the Postgres test target in the Makefile to set IT_GATEWAY_CONTROLLER_HA=true and added documentation describing the two-controller topology
  • Added a new gateway-controller-xds service in the Docker Compose configuration to serve as the runtime-facing controller, alongside the primary controller
  • Reconfigured gateway-runtime to target the new gateway-controller-xds controller via updated host configuration
  • Memory allocations were optimized for the multi-controller setup

Configuration and Monitoring:

  • Added a new GatewayControllerRuntimeAdminPort constant (9093) for health probing and synchronization verification of the runtime controller
  • Implemented port availability checks to fail fast if required ports are unavailable
  • Extended the test state configuration with a PolicySnapshotControllerAdminURL field to support probing different controllers based on topology
  • Added environment-driven logic in the test helpers to select the appropriate policy-chain admin URL based on the test configuration
  • Updated the health check step to probe the correct controller for policy snapshot synchronization based on the active topology

Impact

The test suite now validates the two-controller Postgres setup with proper xDS synchronization probing and Postgres-backed replica coordination, ensuring the system works correctly in high-availability configurations using event-based synchronization.

Walkthrough

This pull request introduces a two-controller topology for PostgreSQL-backed gateway integration tests. A new runtime-facing gateway-controller service is added to the Docker Compose configuration to handle policy-chain xDS synchronization, separate from the management REST controller. An environment variable IT_GATEWAY_CONTROLLER_RUNTIME gates the runtime controller path. Helper functions detect this setting and route policy snapshot synchronization probes to the runtime controller's admin port (9093), with fallback to the management controller. Test configuration, suite initialization, build targets, and GitHub workflow are updated to enable and wire the runtime controller selection.

Sequence Diagram

sequenceDiagram
  participant GitHubWorkflow
  participant Makefile
  participant SuiteInit as InitializeTestSuite
  participant Detector as policySnapshotControllerAdminURL
  participant Config
  participant HealthProbe as waitForPolicySnapshotSync
  participant RuntimeCtrl as gateway-controller-xds

  GitHubWorkflow->>Makefile: IT_GATEWAY_CONTROLLER_RUNTIME=true
  Makefile->>SuiteInit: make test-integration
  SuiteInit->>Detector: Check IT_GATEWAY_CONTROLLER_HA
  alt Runtime Enabled
    Detector->>Config: Set PolicySnapshotControllerAdminURL
    Config->>HealthProbe: Provide runtime controller URL
    HealthProbe->>RuntimeCtrl: Probe /xds_sync_status
  else Runtime Disabled
    Detector->>Config: Use default GatewayControllerAdminURL
    Config->>HealthProbe: Provide management controller URL
  end
  HealthProbe->>RuntimeCtrl: Verify policy-chain sync
Loading
  • Suggested reviewers:
    • pubudu538
    • malinthaprasan
    • AnuGayan
    • CrowleyRajapakse
    • RakhithaRR
    • HeshanSudarshana
    • Tharsanan1
    • HiranyaKavishani
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is a template with all sections present but not populated with concrete details, specifics, or answers to required prompts. Complete all template sections with concrete details: explain the underlying problems and why this change is needed, describe the solutions implemented, document the implementation approach, list affected user stories, specify test coverage, provide security check confirmations, and detail the test environment matrix.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding two gateway controllers to the Postgres test suite to test based on eventing. It aligns with the file modifications and objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@VirajSalaka VirajSalaka force-pushed the it-two-controller branch 2 times, most recently from d374518 to 9478464 Compare June 2, 2026 04:08
…ed on eventing

Update workflow file to include IT_GATEWAY_CONTROLLER_RUNTIME=true flag

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@gateway/it/setup.go`:
- Around line 54-58: CheckPortsAvailable() currently omits the new
GatewayControllerRuntimeAdminPort ("9093"), so pre-flight port validation won't
catch conflicts for the runtime admin port; update the CheckPortsAvailable
function to include GatewayControllerRuntimeAdminPort (value "9093") in its
list/set of ports to check (the same place where other gateway ports are listed)
so the validation fails fast before docker-compose startup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e37c36c-20b4-4611-9be9-290762c0bf6c

📥 Commits

Reviewing files that changed from the base of the PR and between 902df87 and 80fd466.

📒 Files selected for processing (8)
  • .github/workflows/gateway-integration-test-postgres.yml
  • gateway/it/Makefile
  • gateway/it/db_helpers.go
  • gateway/it/docker-compose.test.postgres.yaml
  • gateway/it/setup.go
  • gateway/it/state.go
  • gateway/it/steps_health.go
  • gateway/it/suite_test.go

Comment thread gateway/it/setup.go
# Runtime-facing gateway-controller replica. The integration tests continue to
# send management REST calls to gateway-controller above; this controller only
# serves xDS to gateway-runtime after synchronizing through Postgres/EventHub.
gateway-controller-runtime:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This service name confused me at first glance. Because we already have gateway-runtime. What if we rename this to gateway-controller-dataplane or gateway-controller-xds?

Suggested change
gateway-controller-runtime:
gateway-controller-dataplane:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
gateway/it/docker-compose.test.postgres.yaml (1)

75-76: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Monitor test stability after 50% memory reduction.

The management controller's memory has been halved from 1000m to 500m. While the xDS serving load is now handled by gateway-controller-xds, the management controller still processes REST API calls, subscription events, and Postgres writes. Verify that 500m is sufficient under test load.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@gateway/it/docker-compose.test.postgres.yaml` around lines 75 - 76, Memory
for the management controller has been reduced by changing mem_limit and
mem_reservation from 1000m to 500m; run the test suite and a simulated load
(REST calls, subscription events, Postgres writes) against the management
controller and monitor for OOMs, increased latency, failed subscriptions, or DB
write errors; if stability/regressions appear, restore mem_limit/mem_reservation
to 1000m or incrementally increase until stable, or alternatively move heavier
workload(s) to gateway-controller-xds and ensure resource limits/requests are
adjusted accordingly.
🧹 Nitpick comments (1)
gateway/it/Makefile (1)

65-65: 💤 Low value

Environment variable wiring is correct.

The IT_GATEWAY_CONTROLLER_HA=true flag correctly propagates through db_helpers.policySnapshotControllerAdminURL()suite_test.go initialization → steps_health.waitForPolicySnapshotSync() to target the runtime controller's admin port (9093).

💡 Optional: Consider renaming for clarity

The IT_GATEWAY_CONTROLLER_HA name suggests high availability (redundancy/failover), but this topology implements a split management/runtime controller pattern. Consider renaming to IT_GATEWAY_CONTROLLER_RUNTIME or IT_GATEWAY_CONTROLLER_SPLIT for clearer intent, unless "HA" is intentional for future high-availability plans.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@gateway/it/Makefile` at line 65, The environment var IT_GATEWAY_CONTROLLER_HA
is correctly wired but its name may be misleading; if you want clarity rename
the flag and all references (Makefile target line, usages in
db_helpers.policySnapshotControllerAdminURL(), suite_test.go initialization, and
steps_health.waitForPolicySnapshotSync()) to a clearer identifier like
IT_GATEWAY_CONTROLLER_RUNTIME or IT_GATEWAY_CONTROLLER_SPLIT, ensuring you
update every occurrence and related docs/tests so behavior is unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@gateway/it/docker-compose.test.postgres.yaml`:
- Around line 75-76: Memory for the management controller has been reduced by
changing mem_limit and mem_reservation from 1000m to 500m; run the test suite
and a simulated load (REST calls, subscription events, Postgres writes) against
the management controller and monitor for OOMs, increased latency, failed
subscriptions, or DB write errors; if stability/regressions appear, restore
mem_limit/mem_reservation to 1000m or incrementally increase until stable, or
alternatively move heavier workload(s) to gateway-controller-xds and ensure
resource limits/requests are adjusted accordingly.

---

Nitpick comments:
In `@gateway/it/Makefile`:
- Line 65: The environment var IT_GATEWAY_CONTROLLER_HA is correctly wired but
its name may be misleading; if you want clarity rename the flag and all
references (Makefile target line, usages in
db_helpers.policySnapshotControllerAdminURL(), suite_test.go initialization, and
steps_health.waitForPolicySnapshotSync()) to a clearer identifier like
IT_GATEWAY_CONTROLLER_RUNTIME or IT_GATEWAY_CONTROLLER_SPLIT, ensuring you
update every occurrence and related docs/tests so behavior is unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 291204d7-ddb2-4dd7-8370-68e681b17264

📥 Commits

Reviewing files that changed from the base of the PR and between 80fd466 and f806046.

📒 Files selected for processing (8)
  • .github/workflows/gateway-integration-test-postgres.yml
  • gateway/it/Makefile
  • gateway/it/db_helpers.go
  • gateway/it/docker-compose.test.postgres.yaml
  • gateway/it/setup.go
  • gateway/it/state.go
  • gateway/it/steps_health.go
  • gateway/it/suite_test.go
✅ Files skipped from review due to trivial changes (1)
  • gateway/it/suite_test.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • gateway/it/setup.go
  • .github/workflows/gateway-integration-test-postgres.yml
  • gateway/it/steps_health.go
  • gateway/it/db_helpers.go
  • gateway/it/state.go

@renuka-fernando renuka-fernando merged commit 66e4674 into wso2:main Jun 11, 2026
5 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants